home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / scripts / checkmem.awk next >
Text File  |  1996-08-16  |  841b  |  35 lines

  1. BEGIN { AllocMem["00000000"]=0; }
  2. /Call AllocMem/ {
  3.     match($3,/[0-9]+/);
  4.     count=int(substr($3,RSTART,RLENGTH));
  5. }
  6. /Exit AllocMem=/ {
  7.     match($2,/\=/);
  8.     addr=substr($2,RSTART+1,8);
  9.     AllocMem[addr]=count;
  10. }
  11. /Call FreeMem/ {
  12.     match($3,/[0-9a-fA-F]+/);
  13.     addr=substr($3,RSTART,RLENGTH);
  14.     count=int($4);
  15.  
  16.     if (!(addr in AllocMem) )
  17.     {
  18.     printf ("Free of %d bytes of non-allocated memory at %s\n", count, addr);
  19.     }
  20.     else if (AllocMem[addr] != count)
  21.     {
  22.     if (!AllocMem[addr])
  23.         printf ("Free of %d bytes of already freed memory at %s\n", count, addr);
  24.     else
  25.         printf ("Size mismatch at %s (AllocMem(%d), FreeMem(%d))\n", addr, AllocMem[addr], count);
  26.     }
  27. }
  28. END {
  29.     for (addr in AllocMem)
  30.     {
  31.     if (AllocMem[addr] != 0)
  32.         printf ("Unfreed memory of %d bytes at %s\n", AllocMem[addr], addr);
  33.     }
  34. }
  35.